package com.youxin.busfoundation.enums;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.youxin.busfoundation.common.GlobalConfig;
import com.youxin.busfoundation.common.KeyValue;
import com.youxin.foundation.utils.DateUtil;

/**
 * 企业成立年限 1年以内
1-3年
3-5年
5-10年
10年以上
 * @author yingde.cao
 *
 */
public enum EnterpriseEstablishTimeType {
	
	All(0,"所有",0,0),
	Less1Year(1,"1年以内",0,GlobalConfig.YEARS_DAYS),
	Less3Year(2,"1-3年",GlobalConfig.YEARS_DAYS,3*GlobalConfig.YEARS_DAYS),
	Less5Year(3,"3-5年",3*GlobalConfig.YEARS_DAYS,5*GlobalConfig.YEARS_DAYS),
	Less10Year(4,"5-10年",5*GlobalConfig.YEARS_DAYS,10*GlobalConfig.YEARS_DAYS),
	Greater10Year(5,"10年以上",10*GlobalConfig.YEARS_DAYS,0),	
	;
	
	public int getValue() {
		return value;
	}
	
	private int min,max;

	public int getMin() {
		return min;
	}

	public void setMin(int min) {
		this.min = min;
	}

	public int getMax() {
		return max;
	}

	public void setMax(int max) {
		this.max = max;
	}

	private int value;
	private String name;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setValue(int value) {
		this.value = value;
	}

	private EnterpriseEstablishTimeType(int value,String name,int min,int max) {
		this.value = value;
		this.name=name;
		this.min=min;
		this.max=max;
	}
	
	public static EnterpriseEstablishTimeType valueOf(int val)
	{			
		for(EnterpriseEstablishTimeType m : EnterpriseEstablishTimeType.values()) 
		{
			if(val==m.getValue())
				return m;
	    }
		return null;
	}
	
	public static List<KeyValue<Integer, String>> keyValues(){
		List<KeyValue<Integer, String>>  list=new ArrayList<>(6);
		for(EnterpriseEstablishTimeType m : EnterpriseEstablishTimeType.values()) 
		{
			KeyValue<Integer, String> keyValueItem=new KeyValue<>(m.getValue(),m.getName());
			list.add(keyValueItem);
	    }
		return list;
	}
	
	public Date startDate()
	{		
		return DateUtil.addDayDate(new Date(), 0-max);
	}
	
	public Date endDate()
	{		
		return DateUtil.addDayDate(new Date(), 0-min);
	}
	
}
